﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace PubSubLite.Messaging.Threading
{
    internal class InvokeArgs
    {
        public enum InvokeTypes
        {
            Delegate,
            MethodInfo
        }

        public InvokeArgs(object obj, MethodInfo methodInfo, object[] methodArgs)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            if (methodInfo == null)
            {
                throw new ArgumentNullException("methodInfo");
            }
            if (methodArgs == null)
            {
                throw new ArgumentNullException("methodArgs");
            }
            Object = obj;
            MethodInfo = methodInfo;
            Args = methodArgs;
            InvokeType = InvokeTypes.MethodInfo;
        }

        public InvokeArgs(Delegate handler, object arg)
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            Handler = handler;
            Arg = arg;
            InvokeType = InvokeTypes.Delegate;
        }

        public object Object { get; private set; }

        public MethodInfo MethodInfo { get; private set; }

        public Delegate Handler { get; private set; }

        public object[] Args { get; private set; }

        public object Arg { get; private set; }

        public InvokeTypes InvokeType { get; private set; }
    }
}
